To master the life cycle of a C++ object is to command the very mechanics of existence within the heap and stack. Copy control defines how a class manages its lifetime through two operations: the copy constructor and the copy-assignment operator.
1. Initialization vs. Assignment
Direct initialization (e.g., string dots(10, '.')) invokes a constructor directly. However, copy initialization (string s2 = dots) relies on the copy constructor. Unlike initialization, assignment (trans = accum) overwrites an existing object using operator=. A critical constraint: the copy constructor's parameter must be a reference (const Foo&); otherwise, passing an argument by value would trigger an infinite recursive loop of copy calls.
2. The Role of Synthesis
If you don't define these members, the compiler provides synthesized versions that perform memberwise copies. Beware: while sufficient for simple types, these often fail for classes managing dynamic memory, leading to dangling pointers or double-frees.